export function dateAdd(arrive, dayNum) {
    let timeStamp = Date.parse(arrive) / 1000
    timeStamp += 86400 * dayNum
    return new Date(parseInt(timeStamp) * 1000)
}
export function sub(start,end) {
    function formatDate(now) {
        var year = now.getFullYear(); //获取获取当前年份  
        var month = now.getMonth() + 1; //获取获取当前月份
        var date = now.getDate(); //获取获取当前日期
        var hour = now.getHours(); //获取时
        var minute = now.getMinutes(); //获取分  
        var second = now.getSeconds(); //获取秒
        //时间格式 ：年-月-日   
        return year + "-" + month + "-" + date;
    }

    function GetDateDiff(startDate, endDate) {
        var startTime = new Date(Date.parse(startDate.replace(/-/g, "/"))).getTime();
        var endTime = new Date(Date.parse(endDate.replace(/-/g, "/"))).getTime();
        var dates = Math.floor((startTime - endTime)) / (1000 * 60 * 60 * 24);
        return dates;
    }
    //示例
    var current_time = start //当前时间戳 
    var old_time = end
    var current_time = formatDate(current_time);
    var old_time = formatDate(old_time);
    //计算时间差
    return GetDateDiff(current_time, old_time)
}